home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / quicktime / all java / quicktime for java / zoo tutorial / module 5- custom controllers / source / zoo5.java < prev   
Encoding:
Java Source  |  2000-06-23  |  4.7 KB  |  128 lines

  1. import java.awt.*;
  2. import java.awt.event.*;
  3.  
  4. import quicktime.QTSession;
  5. import quicktime.QTException;
  6.  
  7. import quicktime.app.image.GraphicsImporterDrawer;
  8. import quicktime.app.display.QTCanvas;
  9. import quicktime.app.QTFactory;
  10.  
  11. import quicktime.io.QTFile;
  12.  
  13.  
  14. /**
  15.  * QTZoo Module 5 - Custom Controllers
  16.  * This application requires QuickTime for Java 4.1
  17.  *
  18.  * @author Levi Brown
  19.  * @author Michael Hopkins
  20.  * @author Apple Computer, Inc.
  21.  * @version 3.1.3 1/15/2000
  22.  *
  23.  * Copyright:     © Copyright 1999 Apple Computer, Inc. All rights reserved.
  24.  *    
  25.  * Disclaimer:    IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
  26.  *                ("Apple") in consideration of your agreement to the following terms, and your
  27.  *                use, installation, modification or redistribution of this Apple software
  28.  *                constitutes acceptance of these terms.  If you do not agree with these terms,
  29.  *                please do not use, install, modify or redistribute this Apple software.
  30.  *
  31.  *                In consideration of your agreement to abide by the following terms, and subject
  32.  *                to these terms, Apple grants you a personal, non-exclusive license, under Apple’s
  33.  *                copyrights in this original Apple software (the "Apple Software"), to use,
  34.  *                reproduce, modify and redistribute the Apple Software, with or without
  35.  *                modifications, in source and/or binary forms; provided that if you redistribute
  36.  *                the Apple Software in its entirety and without modifications, you must retain
  37.  *                this notice and the following text and disclaimers in all such redistributions of
  38.  *                the Apple Software.  Neither the name, trademarks, service marks or logos of
  39.  *                Apple Computer, Inc. may be used to endorse or promote products derived from the
  40.  *                Apple Software without specific prior written permission from Apple.  Except as
  41.  *                expressly stated in this notice, no other rights or licenses, express or implied,
  42.  *                are granted by Apple herein, including but not limited to any patent rights that
  43.  *                may be infringed by your derivative works or by other works in which the Apple
  44.  *                Software may be incorporated.
  45.  *
  46.  *                The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
  47.  *                WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
  48.  *                WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  49.  *                PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
  50.  *                COMBINATION WITH YOUR PRODUCTS.
  51.  *
  52.  *                IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
  53.  *                CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  54.  *                GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  55.  *                ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
  56.  *                OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
  57.  *                (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
  58.  *                ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  59.  *
  60.  * Revision History
  61.  * ---------------------------------------------------------------------------------
  62.  * 11/15/99 MSH  moved media loading into AnimalPane( ), set client to compositor
  63.  * 12/02/99 MSH  removed superfluous imports, improved formatting and added comments 
  64.  * 01/15/00 MSH  updated code for QTJ 4.1
  65.  */
  66.  
  67. public class Zoo5 extends Frame
  68. {
  69.     static public int WIDTH  = 640;
  70.     static public int HEIGHT = 480;    
  71.  
  72.     /**
  73.      *  Zoo constructor
  74.      *  @param string title of window
  75.      */
  76.     public Zoo5( String s ) 
  77.     {
  78.         super(s);
  79.         setResizable( false );                        // we don't want the window to resize
  80.         setBounds( 0, 0, WIDTH, HEIGHT );            // make window 640x480
  81.         
  82.         QTCanvas myQTCanvas = new QTCanvas( QTCanvas.kInitialSize, 0.5F, 0.5F );
  83.         add( myQTCanvas );
  84.         
  85.         AnimalPane zebraPane = new AnimalPane();    // load media
  86.         try
  87.         {
  88.             myQTCanvas.setClient( zebraPane.getCompositor(), true );
  89.         }
  90.         catch ( QTException e )
  91.         {
  92.             e.printStackTrace();
  93.         }
  94.                 
  95.         addWindowListener( new WindowAdapter()         // anonymous inner class for handling window events
  96.         {
  97.             public void windowClosing( WindowEvent we )
  98.             {
  99.                 QTSession.close();                    // shut down QT and clean up
  100.                 dispose();                            // destroy window
  101.             }
  102.             public void windowClosed( WindowEvent we )
  103.             {
  104.                 System.exit( 0 );                    // exit to shell
  105.             }
  106.         });
  107.     }
  108.  
  109.     /**
  110.      * Main entry point for the application
  111.      */
  112.     public static void main (String[] args)
  113.     {
  114.         try
  115.         {
  116.             QTSession.open();                        // perform native QuickTime initialization
  117.             Zoo5 appWindow = new Zoo5( "QTZoo5" );    // create a new application window
  118.             appWindow.show();                        // make the window visible
  119.             appWindow.toFront();                    // bring it to the front
  120.         }
  121.         catch ( Exception e )                        // handle any exceptions
  122.         {
  123.             QTSession.close();
  124.             e.printStackTrace();
  125.         }
  126.     }
  127. }
  128.